package com.sky.adapter;

import java.util.ArrayList;

import com.sky.Model.Item;
import com.sky.Model.LocationItem;
import com.sky.heathcare.R;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;


public class listLocationAdapter extends ArrayAdapter<LocationItem> {
 Context context;
 int layoutResourceId;
 ArrayList<LocationItem> data = new ArrayList<LocationItem>();
 
 static class LocationHolder {
	  TextView addressTxt;
	  TextView telephone;

	 }

 public listLocationAdapter(Context context, int layoutResourceId,
   ArrayList<LocationItem> data) {
  super(context, layoutResourceId, data);
  this.layoutResourceId = layoutResourceId;
  this.context = context;
  this.data = data;
 }

 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
  View row = convertView;
  LocationHolder holder = null;

  if (row == null) {
   LayoutInflater inflater = ((Activity) context).getLayoutInflater();
   row = inflater.inflate(layoutResourceId, parent, false);

   holder = new LocationHolder();
   holder.addressTxt = (TextView) row.findViewById(R.id.address_text);
   holder.telephone = (TextView) row.findViewById(R.id.phone_text);
   row.setTag(holder);
  } else {
   holder = (LocationHolder) row.getTag();
  }

  LocationItem item = data.get(position);
  holder.addressTxt.setText(item.getAddress());
  holder.telephone.setText(item.getPhone());
  return row;

 }

 
}
